import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'
import Frame from '../layout'

import Test from "@/views/Test";
import RepositoryInfo from "@/views/RepositoryInfo";
import Person from "@/views/Person";
import Company from "@/views/Company";

import CategoryThree from "@/views/CategoryThree";
import BrandInfo from "@/views/BrandInfo";
import SupplierInfo from "@/views/SupplierInfo"
import GoodsSpuInfo from "@/views/GoodsSpuInfo";

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'login',
        component: Login
    },
    {
        path: '/frame',
        name: 'frame',
        component: Frame,
        redirect: '/frame/home',
        children: [
            {
                path: 'home',
                name: 'home',
                component: () => import('../views/Home.vue')
            },
            {
                path: 'test',
                name: 'test',
                component: Test
            },
            {
                path: 'person',
                name: 'person',
                component: Person
            },
            {
                path: 'company',
                name: 'company',
                component: Company
            },
            {
                path: 'repositoryInfo',
                name: 'repositoryInfo',
                component: RepositoryInfo
            },
            {
                path: 'categoryThree',
                name: 'categoryThree',
                component: CategoryThree
            },
            {
                path: 'brandInfo',
                name: 'brandInfo',
                component: BrandInfo
            },
            {
                path: 'supplierInfo',
                name: 'supplierInfo',
                component: SupplierInfo
            },
            {
                path: 'goodsSpuInfo',
                name: 'goodsSpuInfo',
                component: GoodsSpuInfo
            }



        ]
    }
]

const router = new VueRouter({
    routes
})

// 防止连续点击多次路由报错
let routerPush = VueRouter.prototype.push;
let routerReplace = VueRouter.prototype.replace;
// push
VueRouter.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(err => err)
}
// replace
VueRouter.prototype.replace = function push(location) {
    return routerReplace.call(this, location).catch(err => err)
}


export default router
